<template>
  <br />
  &emsp; 死亡日期：<el-date-picker style="width: 100px" v-model="form.start">
  </el-date-picker
  ><el-date-picker style="width: 100px" v-model="form.end"> </el-date-picker
  >&emsp;&emsp; 羊只耳号：<el-select
    style="width: 100px"
    placeholder="请选择"
    v-model="form.sleepInforId"
  >
    <el-option
      v-for="item in SelectEar"
      :label="item.earNumber"
      :value="item.sleepInforId"
    />
  </el-select>
  &nbsp;&nbsp;死亡原因:
  <el-select style="width: 100px" v-model="form.sheepDeathId">
    <el-option
      :label="item.sheepDeathName"
      :value="item.sheepDeathId"
      v-for="item in fieldsDatas"
    />
  </el-select>
  &emsp;&emsp;
  <el-button type="danger" size="large" @click="gettableData()">查询</el-button>

  <br />
  <hr style="font-size: 20px" />
  <br />

  <el-table height="400" border style="width: 100%" :data="tableData">
    <el-table-column type="selection" />
    <el-table-column prop="sheepRaiseDeathId" label="序号" />
    <el-table-column prop="sheepRaiseDeathData" label="死亡日期">
      <template v-slot="scope">
        <span>{{ scope.row.sheepRaiseDeathData.replace('T', ' ') }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="earNumber" label="羊只耳号" />
    <el-table-column prop="sheepDeathName" label="死亡原因"> </el-table-column>
    <el-table-column prop="varietyName" label="品种"> </el-table-column>
    <el-table-column prop="gender" label="性别">
      <template v-slot="scope">
        <span v-if="scope.row.gender == 1">公</span>
        <span v-if="scope.row.gender == 2">母</span>
      </template>
    </el-table-column>
    <el-table-column prop="breedStatuId" label="繁殖状态" />
    <el-table-column label="死亡月龄">
      <template v-slot="scope">
        <span>{{ scope.row.ageDay / 30 }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="ageDay" label="死亡日龄"> </el-table-column>
    <el-table-column prop="cottageName" label="死亡栋舍" />
    <el-table-column prop="fieIdName" label="死亡栏位" />
    <el-table-column prop="sleepBirthDate" label="出生日期">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.sleepBirthDate.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="createId" label="创建人" />
    <el-table-column prop="createTime" label="创建时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.createTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="updateId" label="修改人" />
    <el-table-column prop="updateTime" label="修改时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.updateTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="examId" label="审核人" />
    <el-table-column prop="examTime" label="审核时间">
      <!-- <template v-slot="scope">
        <span>{{ scope.row.examTime.substr(0, 10) }}</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="sheepRaiseDeathCode" label="单据号" />
    <el-table-column prop="name" fixed="right" width="120" label="操作">
      <template #default="scope"> </template>
    </el-table-column>
  </el-table>
</template>

<script setup lang="ts">
import {
  Check,
  Delete,
  Edit,
  Message,
  Back,
  Plus,
  Setting,
  SuccessFilled,
  Minus,
  Close,
} from '@element-plus/icons-vue';
import { reactive, ref, onMounted, computed } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useCounterStore } from '@/stores/counter';

const counterStore = useCounterStore();
const route = useRoute();
const router = useRouter();

onMounted(() => {
  geteweData();
  getcull();
  gettableData();
});

//获取耳号
const SelectEar = ref<any>([]);
const geteweData = () => {
  axios.get('http://localhost:5039/api/SleepBegin/SelectEar').then((res) => {
    SelectEar.value = res.data.item;
  });
};

//死亡原因
const fieldsDatas: any = ref([]);
const getcull = () => {
  axios.post('http://localhost:5039/api/Raise/Handle').then((res) => {
    fieldsDatas.value = res.data.data;
  });
};

const form = reactive({
  start: '',
  end: '',
  sleepInforId: '',
  sheepDeathId: '',
});

const tableData: any = ref([]);
const now = new Date();
const gettableData = () => {
  axios
    .post('http://localhost:5039/api/Raise/Handle/DeathSelect', {
      start: form.start || '',
      end: form.end || '',
      sleepInforId: form.sleepInforId || 0,
      sheepDeathId: form.sheepDeathId || 0,
    })
    .then((res) => {
      tableData.value = res.data.data;
    });
};
</script>

<style scoped></style>
